import { useRef } from 'react'
import EditModal from "@/components/common/EditModal";
import {Button} from "antd";
import ExpertForm from "@/components/tiktok/expert/ExpertForm.tsx";
interface IProps {
    getList: () => void
}

interface IExpertModalRef {
    showModal: () => void
    handleCancel: (cb?: () => void) => void
    handleOk: (cb?: () => void) => void
}

const ExpertAddModal = ({ getList }: IProps) => {
    const expertModalRef = useRef(null)
    const add = () => {
        if(expertModalRef.current) {
            (expertModalRef.current as IExpertModalRef).showModal()
        }
    }
    const cancel = () => {
        if(expertModalRef.current) {
            (expertModalRef.current as IExpertModalRef).handleCancel()
        }
    }
    const ok = () => {
        if(expertModalRef.current) {
            getList();
            (expertModalRef.current as IExpertModalRef).handleOk()
        }
    }
    return (
        <EditModal
            ref={expertModalRef}
            title={'新增达人'}
            footer={null}
            btn={<Button type='primary' onClick={add}>新增</Button>}
            content={ <ExpertForm cancel={ cancel } ok={ok} /> }
        />
    )
}

export default ExpertAddModal